/*
 * btn.h
 *
 * Created: 25/01/2013 14:14:37
 *  Author: marionse
 */ 

#ifndef MOD_BTN_H_
#define MOD_BTN_H_

/************************************************************************/
/* EXTERNAL DECLARATION                                                 */
/************************************************************************/

// Product file must declare a variable and a define as this in his board.h file :
// #define NB_BTN_BUTTON xU // CAN NOT EXCEED 8U
// extern SBtnConfig btnConfig[NB_BTN_BUTTON];


/************************************************************************/
/* PUBLIC DEFINTION                                                     */
/************************************************************************/

/**
* \brief configuration structure for physical button
*/
typedef struct
{
	// hardware definition
	volatile Int8U *io_ddr;		// DDR register of io to use
	volatile Int8U *io_port;	// PORT register of io to use
	volatile Int8U *io_pin;		// PIN register of io to use
	Int8U io_bit;				// BIT of io to use in the register
}SBtnConfig;


// Logical state for one button
#define  BUTTON_STATE_LOW     0U  // GND level
#define  BUTTON_STATE_HIGH    1U  // VCC level

typedef Boolean ButtonState;

// type for status : limited to manage 8 buttons
typedef Int16U BtnStatus;

/************************************************************************/
/* PUBLIC FUNCTIONS                                                     */
/************************************************************************/

/**
* \brief intialising function for button management
*
* \return TRUE if success
*/
Boolean modBtnInit( void );

/**
* \brief function call each loop to chaeck if button status has changed
*
* \return current button status
*/
BtnStatus modButtonTick( void );


#endif /* MOD_BTN_H_ */